from django.db import models
from django.contrib.auth import get_user_model


User = get_user_model()
# Create your models here.

class BlogCategoryModel(models.Model):
    name = models.CharField(max_length=200)


class BlogModel(models.Model):
    title = models.CharField(max_length=200)
    content = models.TextField()
    pub_time = models.DateTimeField(auto_now_add=True)
    category = models.ForeignKey(BlogCategoryModel, on_delete=models.CASCADE)
    author = models.ForeignKey(User, on_delete=models.CASCADE)


class BlogCommentModel(models.Model):
    content = models.TextField()
    pub_time = models.DateTimeField(auto_now_add=True)
    blog = models.ForeignKey(BlogModel, related_name="comments",  on_delete=models.CASCADE)
    author = models.ForeignKey(User, on_delete=models.CASCADE)